package generic

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"sync"
	"webDownloader/engine/base"
)

type DownloadTaskGeneric struct {
	base.DownloadTask
	Context base.Engine
}

func (task *DownloadTaskGeneric) Download(wg *sync.WaitGroup) {
	defer wg.Done()
	fmt.Println("正在下载原始内容...")
	resp, _ := http.DefaultClient.Get(task.Url)
	bytes, _ := io.ReadAll(resp.Body)
	file, _ := os.OpenFile(task.FileName, os.O_RDWR|os.O_CREATE, 0755)
	file.Write(bytes)
	file.Close()
}
